/**
 * 
 */
package xj.toolkit.util;

import java.util.ArrayList;
import java.util.List;

import xj.toolkit.util.ClosureEx;
import xj.toolkit.util.CompositeClosureEx;
import xj.toolkit.util.Functor;

/**
 * @author hp
 *
 */
public class ClosureExDemo {

	private static class DemoClosure1 {
		public void doPrint(int a, String b) {
			System.out.println("1:" + b + a);
		}
	}

	private static class DemoClosure2 {
		public void doPrint(int a, String b) {
			System.out.println("2:" + a + b);
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Functor f1 = new Functor(new DemoClosure1(), "doPrint");
		Functor f2 = new Functor(new DemoClosure2(), "doPrint");

		CompositeClosureEx comp = new CompositeClosureEx();
		List<ClosureEx> closures = new ArrayList<ClosureEx>();

		closures.add(f1);
		closures.add(f2);

		comp.setClosures(closures);

		comp.execute(10, "hello, world!");
	}

}
